package com.juhuixing.user.server.config;

import com.juhuixing.common.swagger.SwaggerUtil;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.ParameterBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.schema.ModelRef;
import springfox.documentation.service.*;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spi.service.contexts.SecurityContext;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;
import java.util.List;

/**
 * 功能描述: 
 * @author: 刘猛
 * @date: 2019/2/21 10:24
 **/
@EnableSwagger2
@Configuration
public class Swagger2Config {
    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .forCodeGeneration(true)
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.juhuixing.user.server.controller"))
                .paths(PathSelectors.any())
                .build()
                .securitySchemes(SwaggerUtil.securitySchemes())
                .securityContexts(SwaggerUtil.securityContexts());
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("用户服务接口文档")
                .description("用户服务接口接口说明文档")
                .termsOfServiceUrl("")
                .contact(new Contact("刘猛","635891879@qq.com","635891879@qq.com"))
                .version("2.0")
                .build();
    }
}
